/************************************************************************
 * SDL_Layer - A layered display mechanism for SDL
 * Copyright (C) 2008-2011  Julien CLEMENT (Andematunum Software)
 *
 * PROJECT HOME : http://code.google.com/p/sdl-layer/
 * MAILING LIST : http://groups.google.com/group/sdl-layer-group
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ************************************************************************/

#ifndef _SDL_Layer_structs_h_
#define _SDL_Layer_structs_h_

#include "SDL.h"

#include "begin_code.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @file SDL_Layer_structs.h
 *  @author Andematunum Software (andematunum@gmail.com)
 *  @brief Internal structures used in the sdl-layer engine.
 */

/** @struct SDLayer
 *  @brief A surface to blit at a particular plane of the display.
 */
typedef struct {
  SDL_Surface* surface;  /**< Bitmap to blit on the screen */

  SDL_Rect rect;         /**< Layer rectangle */
  SDL_Rect* region;      /**< Layer region */
  int visible;           /**< Current visibility  0 (invisible) 1 (visible) */
  float sfactor;         /**< Scrolling factor */

  SDL_Rect* rects;       /**< Dirty rectangles */
  int n_rects;           /**< Number of dirty rectangles */
  int n_chunks;          /**< Number of memory chunks */
} SDLayer;

/** @struct SDLayer_Display
 *  @note The lowest layer is the layer at indice 0 (zero).
 */
typedef struct {
  SDL_Surface* display;  /**< Display surface */

  SDLayer* layers;       /**< Layers */
  int n_layers;          /**< Number of layers */

  int refresh_method;    /**< Decide whether we use a dirty rect (1) <br/>
                           or a whole refresh method (0). <br/>
                           Default is whole refresh. */

  /* Actually the "w" and "h" fields are not changeable,
   * they're initialized to the size of the display surface.
   */
  SDL_Rect viewport;       /**< Sliding window moving on each layer used for scrolling effects. */
  Sint16 origin_x;         /**< Translation vector for relative projection of the layers <br/>
                                to another location than (0,0)  */
  Sint16 origin_y;
  int need_refresh;        /**< Set to one when a blit affect the display */
  int force_whole_refresh; /**< In the dirty rectangles method, discard all the <br/>
                                pending refresh stacks and refresh the whole screen instead. */
} SDLayer_Display;

#ifdef __cplusplus
}
#endif

#endif

